package com.hhit.bigscreenbackmanage.controller.jjgl;

import com.alibaba.fastjson.JSONObject;
import com.hhit.bigscreenbackmanage.common.Response;
import com.hhit.bigscreenbackmanage.service.jjgl.*;
import com.hhit.bigscreenbackmanage.service.jjgl.TJjglWgglMxService;
import com.hhit.bigscreenbackmanage.vo.jjgl.SsXxVO;
import com.hhit.bigscreenbackmanage.vo.jjgl.XyglgzAddVO;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 技经管理接口
 * 2021/7/20 15:20
 * caojie
 */
@RestController
@RequestMapping("jJglController")
public class JjglController {
    // 初设评审月报
    @Resource
    TJjglCspsybService tJjglCspsybService;

    @Resource
    TJjglFbjsfbService tJjglFbjsfbService;

    @Resource
    TJjglGcgsJsjshzbService tJjglGcgsJsjshzbService;

    @Resource
    TJjglJjzdgzydxjService tJjglJjzdgzydxjService;

    // 结算项目结算概算金额
    @Resource
    TJjglJsxmJsgsjeService tJjglJsxmJsgsjeService;

    // 施工图预算管理实施情况月报
    @Resource
    TJjglSgtYsglssqkybService tJjglSgtYsglssqkybService;

    @Resource
    TJjglTcxmWggcglgzbBqgbxmService tJjglTcxmWggcglgzbBqgbxmService;

    @Resource
    TJjglTcxmwggcglgzbTcxmService tJjglTcxmwggcglgzbTcxmService;

    // 预算执行情况
    @Resource
    TJjglYszxqkService tJjglYszxqkService;

    // 尾工情况
    @Resource
    TJjglWgxmqkService tJjglWgxmqkService;

    // 农民工工资汇总
    @Resource
    TJjglNmggzHzService tJjglNmggzHzService;

    @Resource
    TJjglWgglMxService tJjglWgglMxService;



    //===============================================================后台列表============================================================
    /**
     * 初设评审月报
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryCspsyb")
    public Response queryCspsyb(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 删除初设评审月报
     * @param jsonObject
     * @return
     */
    @PostMapping("/deleteCspsyb")
    public Response deleteCspsyb(@RequestBody JSONObject jsonObject){
        try {
            List<String> ids = (List<String>)jsonObject.get("ids");
            tJjglCspsybService.deleteById(ids);
            return Response.createResponseBySuccess("删除成功",null);
        }catch (Exception e){
            return Response.createResponseByError("删除失败:"+e.getMessage());
        }
    }

    /**
     * 分部计算附表
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryFbjsfb")
    public Response queryFbjsfb(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglFbjsfbService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 工程概算，结算，决算汇总表
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryGcgsJsjshzb")
    public Response queryGcgsJsjshzb(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglGcgsJsjshzbService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 技经月度工作总结
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryZdgzydxj")
    public Response queryZdgzydxj(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglJjzdgzydxjService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 结算项目结算概算金额
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryJsxmJsgsje")
    public Response queryJsxmJsgsje(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglJsxmJsgsjeService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 施工图预算管理实施情况月报
     * @param jsonObject
     * @return
     */
    @PostMapping("/querySgtYsglssqkyb")
    public Response querySgtYsglssqkyb(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglSgtYsglssqkybService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 投产项目尾工过程管理跟踪表-本期关闭项目
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryTcxmWggcglgzbBqgbxm")
    public Response queryTcxmWggcglgzbBqgbxm(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglTcxmWggcglgzbBqgbxmService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 投产项目尾工过程管理跟踪表-投产项目
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryTcxmWggcglgzbTcxm")
    public Response queryTcxmWggcglgzbTcxm(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglTcxmwggcglgzbTcxmService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 各单位预算执行情况
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryYszxqk")
    public Response queryYszxqk(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglYszxqkService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 农民工工资汇总
     * @param jsonObject
     * @return
     */
    @PostMapping("/queryNmggzHz")
    public Response queryNmggzHz(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglNmggzHzService.queryAllByLimit(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 尾工情况一览
     * @param
     * @return
     */
    @PostMapping("/getWgxmqk")
    public Response getWgxmqk(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglWgxmqkService.getWgxmqk(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 尾工管理明细
     * @param obj
     * @return
     */
    @PostMapping("/getWgglmx")
    public Response getWgglmx(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglWgglMxService.getWgglmx(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 尾工管理柱状图
     * @param obj
     * @return
     */
    @PostMapping("/getWggltj")
    public Response getWggltj(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglWgglMxService.getWggltj(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 新增下月管理工作
     * @param
     * @return
     */
    @PostMapping("/addXyGlgz")
    public Response addXyGlgz(@RequestBody XyglgzAddVO list){
        try {
            tJjglCspsybService.addXyGlgz(list);
            return Response.createResponseBySuccess("成功",null);
        }catch (Exception e){
            return Response.createResponseByError("失败:"+e.getMessage());
        }
    }

    //===============================================================大屏统计============================================================
    /**
     * 三算信息
     * @param
     * @return
     */
    @PostMapping("/getSsxx")
    public Response getSsxx(@RequestBody SsXxVO obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getSsxx(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    @PostMapping("/getJjglSsxx")
    public Response getJjglSsxx(@RequestBody SsXxVO obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getJjglSsxx(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 预算执行情况
     * @param
     * @return
     */
    @PostMapping("/getYszxqk")
    public Response getYszxqk(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglYszxqkService.getYszxqk(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 概算估算偏差
     * @param
     * @return
     */
    @PostMapping("/getGsGsPc")
    public Response getGsGsPc(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getGsGsPc(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 基建项目预算执行
     * @param
     * @return
     */
    @PostMapping("/getJjXmYsZx")
    public Response getJjXmYsZx(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglYszxqkService.getJjXmYsZx(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     *基建项目预算执行右侧柱状图
     * @param obj
     * @return
     */
    @PostMapping("/getJjXmYsZxBar")
    public Response getJjXmYsZxBar(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglYszxqkService.getJjXmYsZxBar(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 农民工工资
     * @param
     * @return
     */
    @PostMapping("/getNMggz")
    public Response getNMggz(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getNMggz(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 竣工结算
     * @param
     * @return
     */
    @PostMapping("/getJgJs")
    public Response getJgJs(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglJsxmJsgsjeService.getJgJs(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    @PostMapping("/getJjglJgjs")
    public Response getJjglJgjs(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglJsxmJsgsjeService.getJjglJgjs(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 月施工图评审
     * @param
     * @return
     */
    @PostMapping("/getSgtPs")
    public Response getSgtPs(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglSgtYsglssqkybService.getSgtPs(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 月施工图评审
     * @param
     * @return
     */
    @PostMapping("/getSgtPsYs")
    public Response getSgtPsYs(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglSgtYsglssqkybService.getSgtPsYs(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 下月管理工作
     * @param
     * @return
     */
    @PostMapping("/getXyGlgz")
    public Response getXyGlgz(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getXyGlgz(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }


    /**
     * 遗留项目尾工进展
     * @param
     * @return
     */
    @PostMapping("/getYlXmWgJz")
    public Response getYlXmWgJz(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglWgxmqkService.getYlXmWgJz(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 规模及以下初设评审意见出具
     * @param
     * @return
     */
    @PostMapping("/getGmJyxCsPsYjCj")
    public Response getGmJyxCsPsYjCj(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getGmJyxCsPsYjCj(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }


    /**
     * 初设评审计划执行
     * @param
     * @return
     */
    @PostMapping("/getCsPsJhZx")
    public Response getCsPsJhZx(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getCsPsJhZx(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }


    //===============================================================大屏-弹出列表============================================================
    /**
     * 大屏-弹出列表-竣工结算
     * @param
     * @return
     */
    @PostMapping("/getJgJs-dp-list")
    public Response getJgJsDpList(@RequestBody JSONObject obj){
        try {
            // 大屏显示加上月份条件
            obj.put("outFlag","dp");
            Map<String, Object> stringObjectMap = tJjglJsxmJsgsjeService.queryAllByLimit(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-遗留项目尾工进展
     * @param
     * @return
     */
    @PostMapping("/getYlXmWgJz-dp-list")
    public Response getYlXmWgJzDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglWgxmqkService.getYlXmWgJzDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-月预算执行
     * @param
     * @return
     */
    @PostMapping("/getYysZx-dp-list")
    public Response getYysZxDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglYszxqkService.getYysZxDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-初设评审计划执行
     * @param
     * @return
     */
    //todo 文档
    @PostMapping("/getCsPsJhZx-dp-list")
    public Response getCsPsJhZxDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getYysZxDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-施工图评审
     * @param
     * @return
     */
    @PostMapping("/getSgtPs-dp-list")
    public Response getSgtPsDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglJjzdgzydxjService.getSgtPsDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-概算估算偏差
     * @param
     * @return
     */
    @PostMapping("/getGsGsPs-dp-list")
    public Response getGsGsPsDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getGsGsPsDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-农民工工资
     * @param
     * @return
     */
    @PostMapping("/getNmgGz-dp-list")
    public Response getNmgGzDpList(@RequestBody JSONObject obj){
        try {
            Map<String, Object> stringObjectMap = tJjglCspsybService.getNmgGzDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }


    /**
     * 大屏-弹出列表-规模及以下初设评审意见出具
     * @param
     * @return
     */
    @PostMapping("/getGmJyxCsPsYjCj-dp-list")
    public Response getGmJyxCsPsYjCjDpList(@RequestBody JSONObject obj){
        try {
            if(StringUtils.isEmpty(obj.get("dataFlag"))
                    || StringUtils.isEmpty(obj.get("dydj"))){
                throw new RuntimeException("必要参数 不能为空");
            }
            Map<String, Object> stringObjectMap = tJjglCspsybService.getGmJyxCsPsYjCjDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 大屏-弹出列表-三算对比
     * @param
     * @return
     */
    @PostMapping("/getSsDb-dp-list")
    public Response getSsDbDpList(@RequestBody JSONObject obj){
        try {
            if(StringUtils.isEmpty(obj.get("dydj"))){
                throw new RuntimeException("必要参数 不能为空");
            }
            Map<String, Object> stringObjectMap = tJjglGcgsJsjshzbService.getSsDbDpList(obj);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询失败:"+e.getMessage());
        }
    }

    /**
     * 首页中屏行政区划根据地市获取数值
     * @param jsonObject
     * @return
     */
    @PostMapping("/getDataByCityname")
    public Response getDataByCityname(@RequestBody JSONObject jsonObject){
        try {
            Map<String, Object> stringObjectMap = tJjglGcgsJsjshzbService.getDataByCityname(jsonObject);
            return Response.createResponseBySuccess("查询成功",stringObjectMap);
        }catch (Exception e){
            return Response.createResponseByError("查询异常:"+e.getMessage());
        }
    }
}
